﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title></title>
    <link href="../../static/css/font.css" rel="stylesheet" />
    <link href="../../static/css/weadmin.css" rel="stylesheet" />
    <link href="../../lib/layui/css/layui.css" rel="stylesheet" />
    <script src="../../../lib/layui/layui.js"></script>
    <style>
        .layui-tab-title .layui-this {
            background: #00ffff;
        }

        .layui-tab-title li {
            border: none;
            display: block;
        }
        .layui-sition{
            margin-left:150px!important;
        }
        .layui-tab-title {
            float: left;
            width: 10%;
            box-sizing: border-box;
            margin-top: 20px;
        }

        .layui-tab-content {
            margin: 0 auto;
            width: 80%;
        }
    </style>
</head>
<body>
    <div class="weadmin-nav">
        <span class="layui-breadcrumb" style="visibility: visible;">
            <a href="#">首页</a><span lay-separator="">/</span>
            <a href="#">查询统计</a><span lay-separator="">/</span>
            <a><cite>未参加培训人员明细</cite></a>
        </span>
        <a class="layui-btn layui-btn-sm" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
            <i class="layui-icon" style="line-height:30px">ဂ</i>
        </a>
    </div>
    <div class="layui-tab">
        <div class="layui-form">
            <div class="layui-inline layui-sition">
                <label class="layui-form-label">起止日期</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="TPReleaseStart" />
                </div>
                <div class="layui-input-inline layui-form-label-inner">
                    <input type="text" class="layui-input" id="TPReleaseEnd" name="TPReleaseEnd" />
                </div>
                <div class="layui-input-inline">
                    <select id="cheduis" name="cheduis" lay-filter="cheduis">
                        <option value=""></option>
                    </select>
                </div>
                <button type="button" class="layui-btn layui-btn-primary" id="find" name="查询"><i class="layui-icon">&#xe615;</i>查询</button>
            </div>
        </div>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <table id="dataList3" lay-filter="dataList3"></table>
                <script id="barDemo" type="text/html">
                    <a class="layui-btn layui-btn-sm layui-btn-normal" lay-event="detail">详细</a>
                </script>
            </div>
        </div>
    </div>

    <script type="text/html" id="toolbar">
        <div class="layui-table-tool-temp">
        <label id="tabTip" >起止时间</label></div>
    </script> 
    <script>
        var cheduiList = [];
        var currentDeptLevelId = 0;
        var cuurentDeptId = 0;
        var th = 0;
        var tw = 0;
        function CourseContentDetailRep(userId, startTime, endTime) {
            layui.use(['layer', 'jquery'], function () {
                var h = th * 1.8;
                var w = tw * 0.7;
                var layer = layui.layer;
                var $ = layui.jquery;
                var contentPage = "traincourseDetailContentcount.html?User_Id=" + userId + "&startTime=" + startTime + "&endTime=" + endTime + "";
                var title = "培训内容详细";
                layer.open({
                    title: title,
                    type: 2,
                    area: [w + "px", h + "px"],
                    //btn: ['确定'],
                    content: contentPage,
                    yes: function (index) {
                        //var res = window["layui-layer-iframe" + index].selectdata();
                        //$("#PrePlanName").val(res.RefName);
                        //prePlanId = res.RefID;
                        //CPID = res.CPID;
                        layer.close(index);
                    }
                });
            });
        };
        layui.use(['form', 'laydate', 'table', 'jquery', 'element', 'layer', 'tree', 'util'], function () {
            var laydate = layui.laydate;
            var $ = layui.jquery
                , element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
            laydate.render({ elem: '#TPReleaseStart', trigger: 'click' });
            laydate.render({ elem: '#TPReleaseEnd', trigger: 'click' });
            th = $(document).height() * 0.5;
            tw = $(document).width();
            var table = layui.table;
            var form = layui.form;
            var element = layui.element;
            var layer = layui.layer;
            function defaults() {
                var c = new Date();
                var year = c.getFullYear();
                var month = c.getMonth() + 1;
                var day = c.getDate();
                var hh = 9;
                var mm = 0;
                var star = year + "-" + month + "-" + "01";
                var end = year + "-" + month + "-" + day;
                $("#TPReleaseStart").val(star);
                $("#TPReleaseEnd").val(end);
            }
            function formRenderSelect() {
                form.render('select');
            }
            function Formset() {
                $("#t1").attr("style", "display:none;").removeClass("layui-this");
                $("#c1").attr("style", "display:none;").removeClass("layui-show");
                $("#t2").addClass("layui-this"); $("#c2").addClass("layui-show");
            }
            defaults();
            //未参加培训乘务员 数据开始
            function showList3(v) {
                var chedui_Ids = "0";
                if (v != 0) {
                    chedui_Ids = v;
                }
                else {
                    for (var i = 0; i < cheduiList.length; i++) {
                        var item = cheduiList[i];
                        chedui_Ids += "," + item.id + "";
                    }
                }
                var swhere = JSON.stringify({
                    StartDateTime: $("#TPReleaseStart").val(),
                    EndDateTime: $("#TPReleaseEnd").val(),
                    chedui_Ids: chedui_Ids
                });
                table.render({
                    elem: '#dataList3'
                    , url: ApiUrl + 'TrainCourse/GetCourseStudyCourseuncommittedPerson'
                    //, toolbar: true
                    , toolbar: '#toolbar' //直接传入工具栏模板字符
                    , title: '未培训人员'
                    , id: "dataList3"
                    , headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    }
                    , page: true
                    , cols: [[
                        { field: 'UserID', title: '工号', width: 150 },
                        { field: 'UserName', title: '姓名', width: 300 },
                        { field: 'Groups', title: '指导组', width: 400 },
                        { field: 'Post', title: '职务', width: 300 },
                        { field: 'DepName', title: '部门', width: 300 }
                    ]]
                    , where: { swhere: swhere }
                    , parseData: function (res) { //res 即为原始返回的数据
                        return {
                            "code": res.StatusCode, //解析接口状态
                            "msg": res.Info, //解析提示文本
                            "count": res.Count, //解析数据长度
                            "data": res.Data //解析数据列表
                        };
                    },
                    response: { statusCode: 200 },//规定成功的状态码，默认：0
                    event: true,
                    page: true,
                    done: function (res, curr, count) {
                        //如果是异步请求数据方式，res即为你接口返回的信息。
                        //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                        if (res.data != null) {
                            var p = $(".layui-laypage-skip").find("input[type=text]").val();
                            var c = $(".layui-laypage-limits select").find("option:selected").text().substring(0, 2);
                            var k = (Number(p) - 1) * Number(c);
                            for (var i = 0; i < res.data.length; i++) {
                                var item = res.data[i];
                                var ix = item.Row - 1 - k;
                                $(".layui-table-body table tbody tr[data-index=" + ix + "]").attr("style", dataRowColor[item.TPDepLevel]);
                            }
                            document.getElementById("tabTip").innerText = "合计:" + res.count+"人";
                        }

                        if (res.code == 403) {
                            layer.alert(res.msg, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                    }
                });
            }
            //乘务员 数据结束

            $.ajax({
                url: ApiUrl + "TrainCourse/GetCheduiList",
                type: 'get',
                headers: {
                    "userid": JSON.parse(window.localStorage.authInfo).UserId,
                    "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                },
                success: function (data) {
                    if (data.StatusCode == 200) {
                        if (cheduiList.length <= 0) {
                            for (var f = 0; f < data.Data.length; f++) {
                                var item = data.Data[f];
                                cheduiList.push({ id: item.DepID, name: item.DepName });
                            }
                            GetSelectList(cheduiList, $("#cheduis"), formRenderSelect);
                            SetselectValue($("#cheduis"), cheduiList[0].DepID, formRenderSelect);
                        }
                        showList3(0);
                    }
                    else if (data.StatusCode == 403) {
                        layer.alert(data.Info, function () {
                            top.location.href = "http://" + top.location.host + "/login.html";
                        })
                    }
                    else {
                        layer.msg(data.Info);
                    }
                }
            });
            $("#find").on("click", function () {
                var chedui = $("#cheduis").val();
                if (chedui == "") {
                    chedui = 0;
                }
                showList3(chedui);//车间数据统计
            });
            //监听行工具事件
            table.on('tool(dataList3)', function (obj) {
                var data = obj.data;
                if (obj.event === 'detail') {
                    var start = $("#TPReleaseStart").val();
                    var endtime = $("#TPReleaseEnd").val();
                    CourseContentDetailRep(obj.data.flagId, start, endtime);
                }
            });
            form.on("select(cheduis)", function (data) {
                showList3(data.value);
            });
            //触发事件
            var active = {
                tabAdd: function () {
                    //新增一个Tab项
                    element.tabAdd('demo', {
                        title: '新选项' + (Math.random() * 1000 | 0) //用于演示
                        , content: '内容' + (Math.random() * 1000 | 0)
                        , id: new Date().getTime() //实际使用一般是规定好的id，这里以时间戳模拟下
                    })
                }
                , tabDelete: function (othis) {
                    //删除指定Tab项
                    element.tabDelete('demo', '44'); //删除：“商品管理”


                    othis.addClass('layui-btn-disabled');
                }
                , tabChange: function () {
                    //切换到指定Tab项
                    element.tabChange('demo', '22'); //切换到：用户管理
                }
            };

            $('.site-demo-active').on('click', function () {
                var othis = $(this), type = othis.data('type');
                active[type] ? active[type].call(this, othis) : '';
            });

            //Hash地址的定位
            var layid = location.hash.replace(/^#test=/, '');
            element.tabChange('test', layid);

            element.on('tab(test)', function (elem) {
                location.hash = 'test=' + $(this).attr('lay-id');
            });

        });
    </script>
</body>
</html>    